package cn.edu.zut.controller;


import cn.edu.zut.domain.Contest;
import cn.edu.zut.service.ContestService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import java.util.List;

@Controller
@RequestMapping("/contest")
public class ContestController {

    @Autowired
    private ContestService contestService;

    @RequestMapping("/add.do")
    public @ResponseBody
    void add(Contest contest) {
        contestService.add(contest);
    }

    @RequestMapping("/queryByName.do")
    public @ResponseBody
    List<Contest> findByName(String contestName) {
        return contestService.queryByName(contestName);
    }

    @RequestMapping("/queryAll.do")
    public @ResponseBody
    List<Contest> findAll() {
        return contestService.queryAll();
    }

    @RequestMapping("/modifyContest.do")
    public @ResponseBody
    void modifyContest(Contest contest) {
        contestService.modifyContest(contest);
    }

    @RequestMapping("/deleteContest.do")
    public @ResponseBody
    void deleteContest(Contest contest) {
        contestService.deleteContest(contest);
    }

    @RequestMapping("/findById.do")
    public @ResponseBody
    Contest findById(int id) {
        return contestService.findById(id);
    }

    public void setContestService(ContestService contestService) {
        this.contestService = contestService;
    }
}
